/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.reddys.rad.inventory.utils;

import java.awt.Insets;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBoxBuilder;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;

/**
 *
 * @author REDDYS
 */
public class Utilities {
    
    public static Date getCurrentDate(){
        
        return new Date();
    }
    
    public static String getDisplayDate(){
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        String formattedDate = sdf.format(date);
        return formattedDate;
    }
    
    public static void main(String args[]){
        Utilities.createDialog("");
    }
    
    public static void createDialog(String text){
       final Stage dialogStage = new Stage();
        Button btn = new Button("Ok");
        btn.setOnMouseClicked(new EventHandler<MouseEvent>(){

            @Override
            public void handle(MouseEvent t) {
               dialogStage.close();
            }
            
        });
        dialogStage.initModality(Modality.WINDOW_MODAL);
        dialogStage.setWidth(new Double(200));
        dialogStage.setHeight(new Double(80));
        dialogStage.setScene(new Scene(VBoxBuilder.create().
        children(new Text(text), btn).
        alignment(Pos.CENTER).build()));
        dialogStage.show();
    }

    public static boolean isNull(String text){
        boolean boo  = true;
        if(text !=null && text!="" && !text.equalsIgnoreCase("")){
            boo = false;
        }
        return boo;
    }
    
    public static Logger getLogger(String obj){
        Logger logger = null;
        try {
             logger = Logger.getLogger(obj);
            FileHandler hand = new FileHandler("vk.log");
            logger.addHandler(hand);
        } catch (IOException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SecurityException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
        }

         
        return logger;
    }
}
